const M = require('ming_node');
const next = require('next');
const dev = process.env.NODE_ENV !== 'production';
const nextServer = next({ dev });
const handle = nextServer.getRequestHandler();
const app = M.server();
app.listen(8888);

require("./controller/index");
//ming_node 声明接口
app.get("/api/userList",(req,res)=>{
    res.send(M.result("ok"))
})


nextServer.prepare().then(() => {
    app.use('/*/', (req, res) =>{
        console.log(req.url)
            //api 开头的请求交给ming_node处理
            if(!req.url.startsWith("/api")){
                res.alreadySend = true;
                handle(req, res);
            }
        }
    );
});